/*  1:   */ package org.intellij.lang.regexp.validation;
/*  2:   */ 
/*  3:   */

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlElement;
import com.intellij.util.IncorrectOperationException;
import com.intellij.xml.util.XmlStringUtil;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.RegExpChar;
import org.intellij.lang.regexp.psi.impl.RegExpElementImpl;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */ 
/* 18:   */ class RemoveRedundantEscapeAction
/* 19:   */   implements IntentionAction
/* 20:   */ {
/* 21:   */   private final RegExpChar a;
/* 22:   */   
/* 23:   */   public RemoveRedundantEscapeAction(RegExpChar paramRegExpChar)
/* 24:   */   {
/* 25:37 */     this.a = paramRegExpChar;
/* 26:   */   }
/* 27:   */   
/* 28:   */   @NotNull
/* 29:   */   public String getText()
/* 30:   */   {
/* 31:42 */     String tmp2_0 = "Remove Redundant Escape";
/* 32:42 */     if (tmp2_0 == null) {
/* 33:42 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/validation/RemoveRedundantEscapeAction", "getText" }));
/* 34:   */     }
/* 35:42 */     return tmp2_0;
/* 36:   */   }
/* 37:   */   
/* 38:   */   @NotNull
/* 39:   */   public String getFamilyName()
/* 40:   */   {
/* 41:47 */     String tmp2_0 = "Redundant Character Escape";
/* 42:47 */     if (tmp2_0 == null) {
/* 43:47 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/validation/RemoveRedundantEscapeAction", "getFamilyName" }));
/* 44:   */     }
/* 45:47 */     return tmp2_0;
/* 46:   */   }
/* 47:   */   
/* 48:   */   public boolean isAvailable(@NotNull Project paramProject, Editor paramEditor, PsiFile paramPsiFile)
/* 49:   */   {
/* 50:51 */     if (paramProject == null) {
/* 51:51 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/validation/RemoveRedundantEscapeAction", "isAvailable" }));
/* 52:   */     }
/* 53:51 */     return (this.a.isValid()) && (this.a.getUnescapedText().startsWith("\\"));
/* 54:   */   }
/* 55:   */   
/* 56:   */   public void invoke(@NotNull Project paramProject, Editor paramEditor, PsiFile paramPsiFile)
/* 57:   */     throws IncorrectOperationException
/* 58:   */   {
/* 59:55 */     if (paramProject == null) {
/* 60:55 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/validation/RemoveRedundantEscapeAction", "invoke" }));
/* 61:   */     }
/* 62:55 */     Character localCharacter = this.a.getValue();
/* 63:56 */     assert (localCharacter != null);
/* 64:   */     
/* 65:58 */     ASTNode localASTNode1 = this.a.getNode().getFirstChildNode();
/* 66:59 */     ASTNode localASTNode2 = localASTNode1.getTreeParent();
/* 67:60 */     localASTNode2.addLeaf(RegExpTT.CHARACTER, a(localCharacter), localASTNode1);
/* 68:61 */     localASTNode2.removeChild(localASTNode1);
/* 69:   */   }
/* 70:   */   
/* 71:   */   private String a(Character paramCharacter)
/* 72:   */   {
/* 73:65 */     PsiElement localPsiElement = this.a.getContainingFile().getContext();
/* 74:66 */     return (localPsiElement instanceof XmlElement) ? XmlStringUtil.escapeString(paramCharacter.toString()) : RegExpElementImpl.isLiteralExpression(localPsiElement) ? StringUtil.escapeStringCharacters(paramCharacter.toString()) : paramCharacter.toString();
/* 75:   */   }
/* 76:   */   
/* 77:   */   public boolean startInWriteAction()
/* 78:   */   {
/* 79:74 */     return true;
/* 80:   */   }
/* 81:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.validation.RemoveRedundantEscapeAction

 * JD-Core Version:    0.7.0.1

 */